<?php

/**
 * Invoice filter form base class.
 *
 * @package    corpon
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseInvoiceFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_transaction'     => new sfWidgetFormFilterInput(),
      'auth_code'          => new sfWidgetFormFilterInput(),
      'message'            => new sfWidgetFormFilterInput(),
      'result'             => new sfWidgetFormFilterInput(),
      'status'             => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'is_paid'            => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'invoice_amount'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'shipping_amount'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'tax_amount'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'shipping_name'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'shipping_last_name' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'shipping_company'   => new sfWidgetFormFilterInput(),
      'shipping_address'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'shipping_state'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'shipping_city'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'shipping_zip'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'billing_address'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'billing_state'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'billing_city'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'billing_zip'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'billing_phone'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'billing_fax'        => new sfWidgetFormFilterInput(),
      'billing_email'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'billing_name'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'billing_last_name'  => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'billing_company'    => new sfWidgetFormFilterInput(),
      'payment_date'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'created_at'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'id_user'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'id_transaction'     => new sfValidatorPass(array('required' => false)),
      'auth_code'          => new sfValidatorPass(array('required' => false)),
      'message'            => new sfValidatorPass(array('required' => false)),
      'result'             => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'status'             => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'is_paid'            => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'invoice_amount'     => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'shipping_amount'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'tax_amount'         => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'shipping_name'      => new sfValidatorPass(array('required' => false)),
      'shipping_last_name' => new sfValidatorPass(array('required' => false)),
      'shipping_company'   => new sfValidatorPass(array('required' => false)),
      'shipping_address'   => new sfValidatorPass(array('required' => false)),
      'shipping_state'     => new sfValidatorPass(array('required' => false)),
      'shipping_city'      => new sfValidatorPass(array('required' => false)),
      'shipping_zip'       => new sfValidatorPass(array('required' => false)),
      'billing_address'    => new sfValidatorPass(array('required' => false)),
      'billing_state'      => new sfValidatorPass(array('required' => false)),
      'billing_city'       => new sfValidatorPass(array('required' => false)),
      'billing_zip'        => new sfValidatorPass(array('required' => false)),
      'billing_phone'      => new sfValidatorPass(array('required' => false)),
      'billing_fax'        => new sfValidatorPass(array('required' => false)),
      'billing_email'      => new sfValidatorPass(array('required' => false)),
      'billing_name'       => new sfValidatorPass(array('required' => false)),
      'billing_last_name'  => new sfValidatorPass(array('required' => false)),
      'billing_company'    => new sfValidatorPass(array('required' => false)),
      'payment_date'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'created_at'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'id_user'            => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('User'), 'column' => 'id_user')),
    ));

    $this->widgetSchema->setNameFormat('invoice_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Invoice';
  }

  public function getFields()
  {
    return array(
      'id_invoice'         => 'Number',
      'id_transaction'     => 'Text',
      'auth_code'          => 'Text',
      'message'            => 'Text',
      'result'             => 'Number',
      'status'             => 'Boolean',
      'is_paid'            => 'Boolean',
      'invoice_amount'     => 'Number',
      'shipping_amount'    => 'Number',
      'tax_amount'         => 'Number',
      'shipping_name'      => 'Text',
      'shipping_last_name' => 'Text',
      'shipping_company'   => 'Text',
      'shipping_address'   => 'Text',
      'shipping_state'     => 'Text',
      'shipping_city'      => 'Text',
      'shipping_zip'       => 'Text',
      'billing_address'    => 'Text',
      'billing_state'      => 'Text',
      'billing_city'       => 'Text',
      'billing_zip'        => 'Text',
      'billing_phone'      => 'Text',
      'billing_fax'        => 'Text',
      'billing_email'      => 'Text',
      'billing_name'       => 'Text',
      'billing_last_name'  => 'Text',
      'billing_company'    => 'Text',
      'payment_date'       => 'Date',
      'created_at'         => 'Date',
      'id_user'            => 'ForeignKey',
    );
  }
}
